handling EOLN at end of output file correctly