Added helper functions. Added seperate FileException class. Added error
checking to helper functions.