Add removal of newlines at beginning of file. Opening and closing files in encapsulated stupidly in functions. Need to fix this
Fixed weirdness in opening and closing files