Fixing issues with filewriter