Updated the file controller for writing to the file