Reviewed s5_write_file