Writing to file is now working