Writing only the number of bytes I read

This prevents me from adding a bunch of zero's at the end
of the file