writing to a text file in main method