Fixed a bug with opening file