A command writes ordinary output to the terminal unless you redirect it. A single greater-than sign replaces a file, even if the command later produces no text. Two signs append instead.
Input redirection supplies a file as the command's input stream. The request here includes an existing opening line that must survive. Inspect the destination before writing, then confirm that the old and new records appear in the right order. The shell sets up redirection before the command reads its input.
That is why cat record.txt > record.txt erases the source before cat can copy it. Use a separate destination for a replacement. Ordinary output and error messages are separate streams; redirecting ordinary output alone leaves a failed command's diagnostic visible.