The contents of the input file are not changed. The sed program is a stream editor that receives its input from standard input, changes that input as directed by commands in a command file, and writes the resulting stream to standard output. If you do not provide a command file and do not use any flags with the sed command, the sed program copies standard input to standard output without change. This stream is the data to be edited. The parameters Line1 and Line2 are called addresses.
Addresses can be either patterns to match in the input stream, or line numbers in the input stream.
You can also enter editing commands along with the sed command by using the -e flag. When sed edits, it reads the input stream one line at a time into an area in memory called the pattern space. When a line of data is in the pattern space, sed reads the command file and tries to match the addresses in the command file with characters in the pattern space. If it finds an address that matches something in the pattern space, sed then performs the command associated with that address on the part of the pattern space that matched the address. The result of that command changes the contents of the pattern space, and thus becomes the input for all following commands.