added methods for writing partial files and writing the complete file