Fixed a long code line and an edge case in opening a file