Fixed bug chopping off newline when outputing to a file.