Fixed bug in writing regular files.