Changed output_file() to read many bytes at a time

Instead of using getc() and putc(), output_file() now reads using a buffer (of 1024 bytes, right now).