Seperated input & output into funcs, successfully reads through whole file