You can't open the file in read mode as you've shown if you plan on writing to that file. You need to open it write or append mode.

You should be using a lexical var for the filehandle instead of the bareword.

You should be using the 3 arg form of open and verify that the open call was successful before continuing.

You haven't provided enough info for us to say if you should keep the file open or close/reopen it every time you need to write to it.

1) How often does the write happen? 2) How much data is being written at each write? 3) Will some other process need to access (read or write to) the file during the running of this script? 4) Can you show us the relevant portion of the script so that we can get a better idea of what you're doing?