Improve error handling, read file line by line instead of the entire thing at a time