reimplemented file output
a little clean-up