Split into more .c files

Moved functions into their own .c files (input.c, output.c and utils.c)