added to_stdout option, fixed fo variable