fixed output file bug