write exit code to file