file_writer works now, and fixed several bugs