Moving print code into my function, some code cleanup, but now read/write discretes seg faults