Fixed bugs with console reader and file writer