Now properly recieve file. Breaks when trying to write to file.