How do I remove certain lines (using line numbers) in a file?

With sed, like so:

sed '20,37d; 45d' < input.txt > output.txt

If you wanted to do this in-place:

sed --in-place '20,37d; 45d' file.txt

If the file fits comfortably in memory, you could also use ed.
The commands are quite similar to the sed one above with one notable difference: you have to pass the list of line numbers/ranges to be deleted in descending order (from the highest line no/range to the lowest one). The reason is that when you delete/insert/split/join lines with ed, the text buffer is updated after each subcommand so if you delete some lines, the rest of the following lines will no longer be at the same position in the buffer when the next subcommand is executed. So you have to start backwards1.
In-place editing:

ed -s in_file <<IN
45d
20,37d
w
q
IN

or

ed -s in_file <<< $'45d\n20,37d\nw\nq\n'

or

printf '%s\n' 45d 20,37d w q | ed -s in_file

Replace write with ,print if you want to print the resulting output instead of writing to file. If you want to keep the original file intact and write to another file you can pass the new file name to the write subcommand:

ed -s in_file <<IN
78,86d
65d
51d
20,37d
w out_file
q
IN

1 Unless you are willing to calculate the new line numbers after each delete, which is quite trivial for this particular case (after deleting lines 20-37, i.e. 18 lines, line 45 becomes line 27) so you could run:

ed -s in_file <<IN
20,37d
27d
w
q
IN

However, if you have to delete multiple line numbers/ranges, working backwards is a no-brainer.