reorder code in write_file_internal to make it more extensible
reorder code in write_file_internal to make it more extensible

hyperair/libgpod,hyperair/libgpod,hyperair/libgpod,neuschaefer/libgpod,neuschaefer/libgpod,neuschaefer/libgpod,hyperair/libgpod,neuschaefer/libgpod,hyperair/libgpod,neuschaefer/libgpod