Removed "Bad file number error" on write