Fixed opening files
Merged and added error catching
Added stack trace when opening a file fails