Leaving with bug in writing to file