merging two file conversion functions into one

they needed identical loops and file reading part