Write to the correct file location