writing to file, correct mapping