write the file in the correct place