Fixed file output. Script is now fully functioning.