You can't modify a sequential file like that. You are amending a copy of the file in memory, then you need to write back your modified content back to a file, either to a new copy of the original file or, if you are sure of what you're doing, back to the original file.